package com.myapp;

import android.app.Activity;
import android.app.Application;

import com.util.ToastUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MyApp extends Application {
    public String comname = "";
    public static String AppId = "";
    public String AppKey = "";
    public String AppSecret = "";
    public int scorenum = 0;
    public int scoreciyu = 0;
    public int scorekanji = 0;
    public int scoretingji = 0;
    public int scoredanci = 0;
    public static String deviceId="";
    public static String device_time="3000";
    public static boolean isRequest=true;

    public static boolean isIsRequest() {
        return isRequest;
    }

    public static void setIsRequest(boolean isRequest) {
        MyApp.isRequest = isRequest;
    }

    public String getDevice_time() {
        return device_time;
    }

    public void setDevice_time(String device_time) {
        this.device_time = device_time;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppId() {
        return AppId;
    }

    public void setAppId(String appId) {
        AppId = appId;
    }

    public String getAppSecret() {
        return AppSecret;
    }

    public void setAppSecret(String appSecret) {
        AppSecret = appSecret;
    }

//                    "is_fenxiang": "0",
//                            "fenxiang_link": "https://www.baidu.com",
//                            "is_viplink": "0",
//                            "vip_link": "http://www.jd.com"

    public String pay_status = "";
    public String pay_status_msg = "";
    public String yanchi_time = "";
    public String banner_time = "";
    public String vip_price = "";
    public String is_fenxiang = "";
    public String fenxiang_link = "";
    public String is_viplink = "";
    public String vip_link = "";
    public String wx_h5_link = "";

    public String getWx_h5_link() {
        return wx_h5_link;
    }

    public void setWx_h5_link(String wx_h5_link) {
        this.wx_h5_link = wx_h5_link;
    }

    public String getPay_status() {
        return pay_status;
    }

    public void setPay_status(String pay_status) {
        this.pay_status = pay_status;
    }

    public String getPay_status_msg() {
        return pay_status_msg;
    }

    public void setPay_status_msg(String pay_status_msg) {
        this.pay_status_msg = pay_status_msg;
    }

    public String getYanchi_time() {
        return yanchi_time;
    }

    public void setYanchi_time(String yanchi_time) {
        this.yanchi_time = yanchi_time;
    }

    public String getBanner_time() {
        return banner_time;
    }

    public void setBanner_time(String banner_time) {
        this.banner_time = banner_time;
    }

    public String getVip_price() {
        return vip_price;
    }

    public void setVip_price(String vip_price) {
        this.vip_price = vip_price;
    }

    public String getIs_fenxiang() {
        return is_fenxiang;
    }

    public void setIs_fenxiang(String is_fenxiang) {
        this.is_fenxiang = is_fenxiang;
    }

    public String getFenxiang_link() {
        return fenxiang_link;
    }

    public void setFenxiang_link(String fenxiang_link) {
        this.fenxiang_link = fenxiang_link;
    }

    public String getIs_viplink() {
        return is_viplink;
    }

    public void setIs_viplink(String is_viplink) {
        this.is_viplink = is_viplink;
    }

    public String getVip_link() {
        return vip_link;
    }

    public void setVip_link(String vip_link) {
        this.vip_link = vip_link;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        this.setTheme(android.R.style.Theme_DeviceDefault_Light_NoActionBar_Fullscreen);
        // 以下是原先的代码实现，保持不变
        if (activityList == null) {
            activityList = new ArrayList<Activity>();
        }
        ToastUtils.init(this);
        // 将“12345678”替换成您申请的APPID，申请地址：http://www.xfyun.cn
// 请勿在“=”与appid之间添加任何空字符或者转义符
//        SpeechUtility.createUtility(this, SpeechConstant.APPID +"=8fa6afb7");




    }
    private ArrayList<Activity> activityList = null;
    public ArrayList<Activity> getActivity() {
        return activityList;
    }



    public static String siteurl ="https://huiduji.bigchun.com";//正式
    public static String siteurlweb ="https://huiduji.bigchun.com/h5";//正式

//    public static String siteurl ="https://d-huiduji.bigchun.com";//测试
//    public static String siteurlweb ="https://d-huiduji.bigchun.com/h5";//测试
    public static String Codeversion = "9_1";
    public static String ImgUrl(String img){
        try {
            if (!img.equals(null) && !img.equals("") && img.length() > 5 ){
                if (img.indexOf("http") == -1) {
                    if(img.indexOf("/") != 0) {
                        img = siteurl + img;
                    }else{
                        img = siteurl +'/'+ img;
                    }
                }
            }
        }catch (Exception e){
            img="";
        }
        return img;
    }
    public String getVersion() {
        return Codeversion;
    }

    public String getWebConfig() {
        return siteurl;
    }

    public static String getSiteurlweb() {
        return siteurlweb;
    }

    /**
     * 添加到销毁队列
     *
     * @param activity 要销毁的activity
     */
    public static void addDestoryActivity(Activity activity, String activityName) {
        destoryMap.put(activityName,activity);
    }

    private static Map<String, Activity> destoryMap = new HashMap<>();
    public static void destoryActivity(String activityName) {
        Set<String> keySet=destoryMap.keySet();
        for (String key:keySet){
            destoryMap.get(key).finish();
        }
    }
}
